<template>
  <div>
    <!-- 头部时间模块 -->
    <div class="contain">
      <div class="model">
        <div class="time">{{ time }} {{ week }}</div>
        <div class="addIn">
          <span title="设为首页" @click="sethome" ref="setHome" id="setHome"
            >设为首页</span
          >
          <span title="加入收藏" @click="addFa">加入收藏</span>
          <span title="联系我们">联系我们</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  dateFormat,
  getWeekDate,
  setHome,
  addFavorite
} from "@/utils/index.js";
export default {
  data() {
    return {
      time: null,
      week: null
    };
  },
  methods: {
    getTime() {
      const date = dateFormat("YYYY年mm月dd日", new Date());
      this.week = getWeekDate();
      this.time = date;
    },
    sethome() {
      setHome(this.$refs.setHome, window.location);
    },
    addFa() {
      addFavorite(window.location.href, document.title);
    }
  },
  mounted() {
    // 获取时间
    this.getTime();
  }
};
</script>

<style scoped lang="scss">
.contain {
  background-color: #ffffff;
  .model {
    width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    height: 48px;

    align-items: center;
    .time,
    .addIn {
      font-size: 14px;
      color: #666666;
    }
    .addIn {
      span {
        margin: 0 16px;
        cursor: pointer;
        &:first-child {
          margin-left: 0;
        }
        &:last-child {
          margin-right: 0;
        }
      }
    }
  }
}
</style>
